package com.qingcloud.fexecutor.base.enums;

/**
 * 外部服务类型接口.
 */
public enum OutsideServiceCategoryEnum {

    DATABASE(1, "数据库"),
    MIDDLE(2, "中间件");

    public final Integer code;
    public final String name;

    OutsideServiceCategoryEnum(int code, String name) {
        this.code = code;
        this.name = name;
    }

    public static String getNameByCode(Integer code) {
        for (OutsideServiceCategoryEnum type : OutsideServiceCategoryEnum.values()) {
            if (code.equals(type.code)) {
                return type.name;
            }
        }
        return "";
    }

    public static OutsideServiceCategoryEnum findByName(String name) {
        for (OutsideServiceCategoryEnum type : OutsideServiceCategoryEnum.values()) {
            if (type.name().equalsIgnoreCase(name)) {
                return type;
            }
        }
        return null;
    }
}
